#ifndef PARAMINFO_H
#define PARAMINFO_H
#include <stdint.h>
#include <QString>
#include <QList>
#include <QVariantList>

#define PARAM_VALUESTR_BUFFX    1024

//
#define    FORDER_BASE "/opt/ForkliftScale/"
//CFG路径
#define     CFG_PATH        FORDER_BASE"cfg/"

typedef struct _S_SPARAMINFO1_
{
    const char* pIniPath;
    char key[32];
    char name[48];
    void* pVar;
    ////////变量类型
    #define VARTYPE_I32         0
    #define VARTYPE_STR         (VARTYPE_I32+1)
    #define VARTYPE_BCD         (VARTYPE_STR+1)
    #define VARTYPE_I32LIST     (VARTYPE_BCD+1)
    #define VARTYPE_DOUBLE      (VARTYPE_I32LIST+1)
    #define VARTYPE_DOUBLELIST  (VARTYPE_DOUBLE+1)
    #define VARTYPE_VARIANTLIST (VARTYPE_DOUBLELIST+1)
    #define VARTYPE_NUM         (VARTYPE_VARIANTLIST+1)
    uint8_t  varType;
    QString defaultValue;
}SPARAMINFO1;

typedef struct _S_SPARAMINFO1_ SPARAMINFO1;

typedef  struct _S_SBASEPARAM_
{
    QString m_setpwd;
    QString m_unit;
    int m_saveInterval;
    double m_upperUpperLimit;
    double m_upperLimit;
    double m_lowerLimit;
    double m_lowerLowerLimit;
    int m_collectTime;
    int m_axisCount;
    int m_backlight;
    int m_screenSaveTime;
    QString m_deviceID;
    QString m_truckNo;
    QList<int> m_slaveIDs;
    QVariantList m_factors;
    QList<double> m_zeroWeights;
    double m_zeroWeight1;
    double m_calThreshold;
    int m_encoderChannel;
    int m_encoderFiltering;
    int m_encoderDirection;
    int m_encoderInterval;
    int m_sensorSlaveID;
    int m_encoderSlaveID;
    int m_pulsePerRev;
    int m_encoderDecimalPlace;
    QString m_deviceType;
    double m_accumulateZero;
    int m_autoSave;
    int m_saveDays;
    int m_language;
    int m_ngCount;
    int m_okCount;
    int m_pwdSwitch;

    QString m_comName;
    int m_baudrate;
    int m_dataBit;
    int m_stopBit;
    int m_parity;

    QString m_comName4g;
    int m_baudrate4g;
    int m_dataBit4g;
    int m_stopBit4g;
    int m_parity4g;

    QString m_comNameEncoder;
    int m_baudrateEncoder;
    int m_dataBitEncoder;
    int m_stopBitEncoder;
    int m_parityEncoder;

    QString m_hostName;
    int m_port;
    QString m_topic;
    QString m_subTopic;
    QString m_userName;
    QString m_password;
    QString m_clientID;
    int m_mqttSwitch;
    int m_mqttInterval;

    QString m_apn;
    QString m_url;
    
    QString m_version;
    QString m_devTime;

    int m_debug4g;
    int m_debugGps;
}SBASEPARAM;

#ifndef MYARRAYSIZE
#define MYARRAYSIZE(_Array) (sizeof(_Array)/sizeof((_Array)[0]))
#endif

extern SBASEPARAM m_sBaseParam;
void BaseParamInit();
bool ParamSetVarFromKey(const char* pKey, bool bForceSave);

#endif